// Longest Palindrome Substring -| Not to be confused with Longest Palindrome Subsequence.

#include<iostream>
using namespace std;

char a[] = "abcdedcdedyzydxedc";
int l[sizeof(a)/sizeof(char)][sizeof(a)/sizeof(char)];

void lps();
int lps(int i, int j);

int main()
{
	lps();	
	return 0;
}

void lps()
{
	int b=0;
	int c=0;
	for(int i=0; i<sizeof(a)/sizeof(char); i++)
	{
		for(int j=0; j<sizeof(a)/sizeof(char); j++)
		l[i][j] = -1;
	}
	
	int max=0;
	for(int i=0; i<sizeof(a)/sizeof(char); i++)
	{
		for(int j=i; j<sizeof(a)/sizeof(char); j++)
		{
			if(max<lps(i,j))
			{
				max = lps(i,j);
				b=i;
				c=j;
			}
		}
	}
	cout << "\n" << max << " : and the index is " << b << "  :  " << c << "\n";
}

int lps(int i, int j)
{
	if(i==j)
	return 1;
	
	if(l[i][j]!=-1)
	return l[i][j];
	
	if(i>j)
	return 0;
	
	if(a[i] == a[j])
	{
		l[i][j] = 2+lps(i+1,j-1);
		return l[i][j];
	}
	return 0;
}
